<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		#include("common/header.html")
		<link type="text/css" rel="stylesheet" href="/css/about.css" />
		<title></title>
	</head>
	<body>
		<header style="background: #005aab;" class="mui-bar mui-bar-nav head">
			<!--<span class="mui-icon mui-icon-back"></span>-->
			<h1 style="color: #FFFFFF; letter-spacing: 4px;" class="mui-title">关于我们</h1>
			<!--<span class="mui-icon mui-icon-more"></span>-->
		</header>
		<nav style="background: #cccccc;" id="bottomx" class="mui-bar mui-bar-tab">
			<a class="mui-tab-item" href="/business/">
				<span class="mui-icon iconfont icon-qiyedengji-copy"></span><br>
				<span class="mui-tab-label">业绩登记</span>
			</a>
			<a class="mui-tab-item " href="/integral/">
				<span class="mui-icon iconfont icon-icon18"></span><br>
				<span class="mui-tab-label">积分兑换</span>
			</a>
			<a class="mui-tab-item mui-active" href="/v/center">
				<span class="mui-icon iconfont icon-gerenzhongxin"></span><br>
				<span class="mui-tab-label">个人中心</span>
			</a>
		</nav>
		<div class="mui-content">
		    <div style="margin-top: 12px;" class="mui-button-row">
		        <button type="button" class="mui-btn mui-btn-primary" onclick="receive(1)" >第一季度</button>
		    </div>
			<div style="margin-top: 12px;" class="mui-button-row">
				<button type="button" class="mui-btn mui-btn-primary" onclick="receive(2)" >第二季度</button>
			</div>
			<div style="margin-top: 12px;" class="mui-button-row">
				<button type="button" class="mui-btn mui-btn-primary" onclick="receive(3)" >第三季度</button>
			</div>
			<div style="margin-top: 12px;" class="mui-button-row">
				<button type="button" class="mui-btn mui-btn-primary" onclick="receive(4)" >第四季度</button>
			</div>
		</div>
	</body>
	<script>
		mui.init();
        nav_tab();

        function receive(quarter) {
            mui.ajax('/business/'+quarter, {
                dataType: 'json',//服务器返回json格式数据
                type: 'post',//HTTP请求类型
                timeout: 10000,//超时时间设置为10秒；
                success: function (r) {
                    //服务器返回响应，根据响应结果，分析是否登录成功；
                    console.log(r);
                    if(r.code == -1){
                        mui.toast(r.msg);
                        return;
                    }

                    doReceive(r.data.integral,r.data.money,quarter);

                },
                error: function (xhr, type, errorThrown) {
                    //异常处理；
                    console.log(type);
                    mui.toast('请求异常,请稍后重试!');
                }
            });
        }
        

        function doReceive(integral,money,quarter) {
            var message = "您在当前季度业绩为" + money + "万,可兑换积分为"+integral+",是否兑换?";
            var title = "提示";

            mui.confirm(message,title,null,function (e) {

                if(e.index == 1) {

                    mui.ajax('/integral/receive', {
                        data: {
                            quarter: quarter
                        },
                        dataType: 'json',//服务器返回json格式数据
                        type: 'post',//HTTP请求类型
                        timeout: 10000,//超时时间设置为10秒；
                        success: function (data) {
                            //服务器返回响应，根据响应结果，分析是否登录成功；
                            console.log(data);
                            if (data.code == -1) {
                                mui.toast(data.msg);
                                return;
                            }

                            mui.toast('领取成功!');
                        },
                        error: function (xhr, type, errorThrown) {
                            //异常处理；
                            console.log(type);
                            mui.toast('请求异常,请稍后重试!');
                        }
                    });
                }
            });
        }
	</script>
</html>
